const nums = [10, 20, [1, 2], [[30, 40]]]
// 数组降维
const newNums = nums.flat()
console.log(newNums);


const newNums2 = nums.flat(2)
console.log(newNums2);

// flatMaop
const nums2 = [10, 20, 30]
const newNums3 = nums2.flatMap(item => {
  return item * 2
})
console.log(newNums3);

// flatMap应用场景
const message = ["hello world", "jay zhou", "what the fuck?"]
const words = message.flatMap(item => {
  return item.split(" ")
})

console.log(words);